import type { ProColumns } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table';
import { tableColumns } from './config';
import { Button } from 'antd';
import { useCallback } from 'react';
import type { IRouteComponentProps } from 'umi';

export default function ClassList({history}: IRouteComponentProps) {
  const newTableColumns: ProColumns<any>[] = [
    {
      title: '操作',
      key: 'option',
      render() {
        return (
          <>
            <Button type="link">编辑</Button>
            <Button type="link">详情</Button>
          </>
        );
      },
    },
    ...tableColumns,
  ];

  const toSave = useCallback(
    () => {
      history.push('/class/save/1');
    },
    [history]
  )
  
  return (
    <ProTable
      search={false}
      columns={newTableColumns}
      options={false}
      toolBarRender={() => [
        <Button key="add" type="primary" onClick={toSave}>
          新增
        </Button>,
      ]}
    />
  );
}
